

export const getTableColumns = ({ params }) => [
	{
		title: "菜单名称",
		dataIndex: "name",
		width: 140,
		ellipsis: true
	},
	{
		title: "菜单类型",
		dataIndex: "type",
		width: 140,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span style={{}}>
					{MENU_TYPE_LIST.find(item => `${item.value}` === `${record.type}`)?.label}
				</span>
			)
		}
	},
	{
		title: "排序",
		dataIndex: "sort",
		width: 140,
		ellipsis: true
	},
	{
		title: "路径",
		dataIndex: "path",
		width: 140,
		ellipsis: true
	},
	{
		title: "可见",
		dataIndex: "status",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span style={{}}>
					{COMMON_STATUS.find(item => `${item.value}` === `${record.status}`)?.label}
				</span>
			)
		}
	},
	{
		title: "权限标识",
		dataIndex: "perms",
		width: 100,
		ellipsis: true,
	},
];

export const COMMON_STATUS = [
	{ label: '隐藏', value: 0 },
	{ label: '显示', value: 1 }
]

export const getSearchColumns = ({orgList}: any) => [
	{
		type: "input",
		placeholder: "菜单名称",
		name: "name"
	},
	{
		type: "select",
		placeholder: "菜单状态",
		name: "status",
		options: COMMON_STATUS
	},
]

export const MENU_TYPE_LIST = [
	{ label: '目录', value: 0 },
	{ label: '菜单', value: 1 },
	{ label: '按钮', value: 2 }
]


export const getCreateColumns = ({menuTree}: any) => {
	return [
		{
			type: "input",
			placeholder: "菜单名称",
			label: "菜单名称",
			name: "name",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "select",
			placeholder: "菜单类型",
			label: "菜单类型",
			name: "type",
			rules: [{ required: true, message: '这是必填项' }],
			options: MENU_TYPE_LIST,
		},
		{
			type: "selectTree",
			placeholder: "父级菜单",
			label: "父级菜单",
			name: "parentId",
			request: () => menuTree?.data,
			fieldProps: {
				treeDefaultExpandAll: true,
				showSearch: false,
				treeNodeFilterProp: 'title',
				fieldNames: {
					label: 'name',
					value: 'id',
					children: 'children',
				},
			}
		},
		{
			type: "input",
			placeholder: "component",
			label: "组件",
			name: "component",
			rules: [{ required: true, message: '这是必填项' }],
		},
		{
			type: "input",
			placeholder: "path",
			label: "path",
			name: "path",
			rules: [{ required: true, message: '这是必填项' }],
		},
		{
			type: "input",
			placeholder: "排序",
			label: "排序",
			name: "sort",
		},
		{
			type: "input",
			placeholder: "图标",
			label: "图标",
			name: "icon",
		},
		{
			type: "input",
			placeholder: "权限字符串",
			label: "权限字符串",
			name: "perms",
		},
		{
			type: "radioGroup",
			placeholder: "状态",
			label: "状态",
			name: "status",
			options: COMMON_STATUS,
		},
	]
}